package com.aaa.day1108.demo03;

/**
 * @author ${崔灿}
 * @date 2022/11/07 17:11
 **/

public class Singleton2 {
    private Singleton2(){}
    //声明一个静态的方法返回本类对象
    private static Singleton2 singleton;
    //提供一个静态的方法返回本类对象
    public static Singleton2 getInstance(){
        synchronized (Singleton2.class) {
            if (singleton == null) {
                singleton=new Singleton2();
            }
        }
        return singleton;
    }
    public void show(){
        System.out.println("这是首位（）");
    }
}
